VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "TestMethodFixture"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private mFixture As MethodFixture
Private mCalled As Boolean
Private mNotify As New MockNotifier
Private mRaise As Boolean

Public Sub testCreation()
givenMethodFixture
thenNameIsAsGiven
thenNotCalled
thenElapsedTimeIs0
End Sub
Public Sub testCallNoMethods()
givenMethodFixture
whenCalled
thenNotCalled
thenElapsedTimeIs0
End Sub
Public Sub testCallOneMethod()
givenMethodFixture
givenMe
whenCalled
thenCalled
thenElapsedTimeIs 1
End Sub
Public Sub testCallTwoMethods()
givenMethodFixture
givenMeTwice
whenCalled
thenCalled
thenElapsedTimeIs 2
End Sub
Public Sub testCallWithError()
givenMethodFixture
givenMe
whenCalledWithError
thenCalled
thenElapsedTimeIs 1
End Sub

''
Private Sub givenMethodFixture()
Set mFixture = New MethodFixture
mFixture.init "name"
End Sub
Private Sub givenMe()
mFixture.Add Me
End Sub
Private Sub givenMeTwice()
givenMe
givenMe
End Sub
Private Sub whenCalled()
mFixture.forward mNotify
End Sub
Private Sub whenCalledWithError()
mRaise = True
whenCalled
End Sub

Private Sub thenNotCalled()
assert.isFalse mCalled, "Not Called"
End Sub
Private Sub thenCalled()
assert.isTrue mCalled, "Called"
End Sub

Private Sub thenNameIsAsGiven()
assert.equals mFixture.name, "name", "Named name"
End Sub
Private Sub thenElapsedTimeIs0()
assert.equals mFixture.elapsedTime, 0, "Time is 0 when not called"
End Sub
Private Sub thenElapsedTimeIs(value As Double)
assert.equals mFixture.elapsedTime, value, "Time is as given"
End Sub


Public Sub forward(notify As Object)
mCalled = True
If mRaise Then
    Err.Raise 1001
End If
End Sub

Public Property Get elapsedTime() As Double
elapsedTime = 1
End Property

'OPTIONAL METHODS
Public Sub setup()
mCalled = False
End Sub

Public Function NumOfAsserts() As Long
NumOfAsserts = 11
End Function

